home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / asm / adisv1_3.lha / src / README_SRC < prev    next >
Encoding:
Text File  |  1995-01-14  |  5.8 KB  |  151 lines

  1. This readme file documents the structure of the source code a bit.
  2. First a short overview how ADis works then a description of each
  3. supplied file and what it does.
  4.  
  5. Overview
  6.  
  7. The  disassembly  part  of  ADis is rather easy.  There's a huge table
  8. which  is  indexed  into by the upper 10 bits of the instruction being
  9. disassembled.   This  table  contains the name of the instruction, two
  10. fields  for  the  allowed addressing modes and a pointer to a function
  11. which  handles  the  details  of  addressing  modes etc.  If there are
  12. multiple instructions with the same bit pattern in the upper 10 bits a
  13. chain of opcode entries is used to check the possible instructions one
  14. by one.  The rest of the disassembly part is a collection of functions
  15. which  handle the entries.  This setup is rather easy but allows for a
  16. very fast disassembly.
  17. The  part  of  ADis which should use the disassembler intelligently to
  18. recognize  data  is a bit more complicated.  ADis keeps a symbol table
  19. for named symbols and labels.  It reads the file to be disassembled up
  20. to  three times.  
  21. The  first  time  only  the  relocation  hunks are read to enter named
  22. symbol  into  the  reference  table.   
  23. The   second  pass  is  the  analysis  pass.   It  keeps  a  table  of
  24. disassembled  parts  of  the file and iteratively tries to find a code
  25. thread.    If  it  finds  a  code  thread  that  contains  an  illegal
  26. instruction  it  backs  up  to  the last secure position and marks the
  27. starting address as data.
  28. The  third pass uses the array the second pass has filled to determine
  29. if  the current location in the program should be disassembled as code
  30. or data.
  31.  
  32.  
  33. A tour through the source files:
  34.  
  35. defs.h
  36. This file contains structures and constant definitions used throughout
  37. the  program.   Additionally  it contains 'extern' definitions for all
  38. global variables as well as prototypes.
  39.  
  40. refs.h
  41. The   file   contains   definitions  for  the  reference  table.   See
  42. ref_table.c for further details.
  43.  
  44. string_recog.h     
  45. This  file  contains  just  one  array  to  determine  the  type  of a
  46. character,  i.e.   if it is printable or not or if it is another valid
  47. character such as linefeed.  The standard isalpha,...  functions could
  48. not  be  used  because I wanted to be able to recognize german Umlauts
  49. also.
  50.  
  51. amiga.c
  52. This  file  contains most of the Amiga specific part of ADis.  This is
  53. mainly for disassembling libraries and devices.  The rest of the Amiga
  54. specific code is in hunks.c.
  55.  
  56. analyze.c
  57. This  is  main 'intelligent' part of ADis.  I'm not particularly proud
  58. of  this  code,  it's  rather  badly  readable.   ADis  first tries to
  59. disassemble  all  parts  of  the program it has some hint that this is
  60. code.   These  are locations that are jumped to.  When this is done it
  61. tries   to  resume  disassembly  at  some  label  that  has  not  been
  62. disassembled  yet.   If this fails too, it merely tries to guess where
  63. to  resume.   In all those cases it might happen, that ADis steps onto
  64. an  illegal instruction which causes backup to the last point of which
  65. ADis is fairly sure.
  66.  
  67. decode_ea.c              
  68. This  file contains only one routine for the decoding of the lower six
  69. bits which contain the addressing mode used.
  70.  
  71. disasm_code.c            
  72. This  file  calls  the disassembly routines appropriately depending on
  73. the type of disassembly wanted (quick or 'intelligent').
  74.  
  75. disasm_data.c
  76. This file disassembles the data and BSS hunks of a file.
  77.  
  78. fpu_opcodes.c            
  79. This  contains  a  small table for the FPU opcodes.  As nearly all FPU
  80. opcodes  start  with  the same upper 10 bits, seven bits of the second
  81. word are used to index into this table.
  82.  
  83. globals.c
  84. Contains all global variables.
  85.  
  86. hunks.c
  87. This  file  reads  a  file in the Amiga load file format and calls the
  88. appropriate routines to disassemble it.  Currently it does not support
  89. the  additional  2.0 hunk types like DREL, because I could not get any
  90. information about these.
  91.  
  92. jmptab.c                 
  93. This file contains code to disassemble jump tables.  Jump tables are a
  94. major difficulty for every disassembler, ADis recognizes at least part
  95. of the often used jump table structures generated by some compilers.
  96.  
  97. main.c                   
  98. The  main  program  file.   Handles  argument  parsing  and  calls the
  99. routines that do the work.
  100.  
  101. mem.c                    
  102. A  very  small  file  only  there  to make memory allocation easier to
  103. handle and to replace.
  104.  
  105. mmu_opcodes.c            
  106. Similar  to  the  FPU opcodes most of the MMU opcodes do not differ in
  107. the  upper  10 bits.  A table for some bits in the second word is used
  108. to call the appropriate function.
  109.  
  110. opcode_handler_cpu.c
  111. These  are  the functions called via the opcode table.  Every function
  112. is  called  with  a  pointer  to  the  current opcode entry and 'code'
  113. pointing to the current instruction.  This way many instructions could
  114. be handled in groups.
  115.  
  116. opcode_handler_fpu.c     
  117. These are the functions for disassembling FPU opcodes.
  118.  
  119. opcode_handler_mmu.c     
  120. These are the functions for disassembling MMU opcodes.
  121.  
  122. opcodes.c
  123. This is the main opcode table.
  124.  
  125. ref_table.c              
  126. This  implements  a  very fast reference table.  It has been tuned for
  127. best performance for finding the next label from the current position,
  128. because this is used by the analyzing pass extensively.
  129.  
  130. user_defined.c           
  131. Handles used-defined labels given on the command line.
  132.  
  133. util.c                   
  134. A  few  string  handling  routines.  These could have been replaced by
  135. sprintf's but I wouldn't like to see ADis working with these (it would
  136. take years).
  137.  
  138.  
  139. This  is  it.  If you like to modify ADis or use parts of it dive into
  140. the  code  and  have  fun.  I know it's documented very well, but it's
  141. been  some  time  ago that I have written this.  If you have questions
  142. regarding  the source code, do not hesitate to ask me.  Contact me via
  143. e-mail if possible.
  144.  
  145. My address is:
  146. apel@gypsy.physik.uni-kl.de
  147.  
  148. Have fun
  149.  
  150. Martin
  151.